package com.tbr.blockchain.model;

import com.tbr.blockchain.security.CryptoUtil;

import java.util.List;

public class Block {
//  索引号
    private  int index;
//  哈希
    private String hash;
//  时间戳
    private long timestamp;
//  交易列表
    private List<Transaction> transactions;
//  随机数
    private int nonce;
//  前个区块的哈希
    private  String previousHash;


    public Block() {
    }

    public Block(int index, String hash, long timestamp, List<Transaction> transactions, int nonce, String previousHash) {
        this.index = index;
        this.hash = hash;
        this.timestamp = timestamp;
        this.transactions = transactions;
        this.nonce = nonce;
        this.previousHash = previousHash;
    }

    /**
     * 获取
     * @return index
     */
    public int getIndex() {
        return index;
    }

    /**
     * 设置
     * @param index
     */
    public void setIndex(int index) {
        this.index = index;
    }

    /**
     * 获取
     * @return hash
     */
    public String getHash() {
        return hash;
    }

    /**
     * 设置
     * @param hash
     */
    public void setHash(String hash) {
        this.hash = hash;
    }

    /**
     * 获取
     * @return timestamp
     */
    public long getTimestamp() {
        return timestamp;
    }

    /**
     * 设置
     * @param timestamp
     */
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    /**
     * 获取
     * @return transactions
     */
    public List<Transaction> getTransactions() {
        return transactions;
    }

    /**
     * 设置
     * @param transactions
     */
    public void setTransactions(List<Transaction> transactions) {
        this.transactions = transactions;
    }

    /**
     * 获取
     * @return nonce
     */
    public int getNonce() {
        return nonce;
    }

    /**
     * 设置
     * @param nonce
     */
    public void setNonce(int nonce) {
        this.nonce = nonce;
    }

    /**
     * 获取
     * @return previousHash
     */
    public String getPreviousHash() {
        return previousHash;
    }

    /**
     * 设置
     * @param previousHash
     */
    public void setPreviousHash(String previousHash) {
        this.previousHash = previousHash;
    }

    public String toString() {
        return "Block{index = " + index + ", hash = " + hash + ", timestamp = " + timestamp + ", transactions = " + transactions + ", nonce = " + nonce + ", previousHash = " + previousHash + "}";
    }
}
